
proc spiral*(n: static int): array[n, array[n, int]] = 
  var num = 1
  let bound = n - 1

  for x in 0..<n div 2:
    var size = bound - 2 * x
    for y in x..<bound - x:
      result[x][y] = num
      result[y][bound - x] = num + size
      result[bound - x][bound - y] = num + size * 2
      result[bound - y][x] = num + size * 3
      num.inc
    num.inc(size * 3)

  when n != 0:
    if n mod 2 == 1:
      result[n div 2][n div 2] = n * n


